package com.job.ZhangMeng.Homework0716;

public class StringBuffer02 {

    public static void main(String[] args) {
        String url="http://loclhost:8080/admin/table/tableList.html";
        StringBuffer sbf=new StringBuffer(url);
        String find="8080";
        String port="9000";
        int index=sbf.indexOf("8080");
        sbf.replace(index, index+find.length(), port);//用port替换find,范围是[ index,index+find.length() )
        url=sbf.toString();
        System.out.println(url);

        int lastIndex=sbf.lastIndexOf("table"); //从末尾开始,记录“table”的下标
        sbf.delete(lastIndex,lastIndex+5);  //视末尾为0,从‘e'删到't'
        url=sbf.toString();
        System.out.println(url);

        sbf.insert(4,'s');  //在sbf[4]插入s
        url=sbf.toString();
        System.out.println(url);

        String src="24420";
        StringBuffer sbf2=new StringBuffer(src);
        String dest=sbf2.reverse().toString();  //翻转、颠倒
        if(src.equals(dest)){
            System.out.println("回文");
        }
    }

}
